package com.huifer.wgx.model;

import com.fasterxml.jackson.annotation.JsonIgnore;
import java.sql.Timestamp;
import java.util.Collection;
import java.util.Objects;
import javax.persistence.Basic;
import javax.persistence.Column;
import javax.persistence.Entity;
import javax.persistence.GeneratedValue;
import javax.persistence.GenerationType;
import javax.persistence.Id;
import javax.persistence.JoinColumn;
import javax.persistence.ManyToOne;
import javax.persistence.OneToMany;
import javax.persistence.Table;

/**
 * <p>Title : WorkEntity </p>
 * <p>Description : </p>
 *
 * @author huifer
 * @date 2019-03-20
 */
@Entity
@Table(name = "t_work", schema = "at15", catalog = "")
public class WorkEntity {

    private Long workId;
    private Long projectId;
    private String workName;
    private Timestamp workStartTime;
    private Timestamp workEndTime;
    private String workExecutionTime;
    private Long personnelId;
    private Collection<FieldLineEntity> tFieldLinesByWorkId;
    private Collection<FieldPointEntity> tFieldPointsByWorkId;
    private Collection<InteriorLineEntity> tInteriorLinesByWorkId;
    private Collection<InteriorPointEntity> tInteriorPointsByWorkId;
    private Collection<ResultLineEntity> tResultLinesByWorkId;
    private Collection<ResultLineAttrEntity> tResultLineAttrsByWorkId;
    private Collection<ResultPointEntity> tResultPointsByWorkId;
    private Collection<ResultPointAttrEntity> tResultPointAttrsByWorkId;
    private Collection<RtkPointEntity> tRtkPointsByWorkId;
    private ProjectEntity tProjectByProjectId;
    private PersonnelEntity tPersonnelByPersonnelId;
    private Collection<FileEntity> tFilesByWorkId;

    @Id
    @Column(name = "work_id")
    @GeneratedValue(strategy = GenerationType.IDENTITY)
    public Long getWorkId() {
        return workId;
    }

    public void setWorkId(Long workId) {
        this.workId = workId;
    }

    @Basic
    @Column(name = "project_id")
    public Long getProjectId() {
        return projectId;
    }

    public void setProjectId(Long projectId) {
        this.projectId = projectId;
    }

    @Basic
    @Column(name = "work_name")
    public String getWorkName() {
        return workName;
    }

    public void setWorkName(String workName) {
        this.workName = workName;
    }

    @Basic
    @Column(name = "work_start_time")
    public Timestamp getWorkStartTime() {
        return workStartTime;
    }

    public void setWorkStartTime(Timestamp workStartTime) {
        this.workStartTime = workStartTime;
    }

    @Basic
    @Column(name = "work_end_time")
    public Timestamp getWorkEndTime() {
        return workEndTime;
    }

    public void setWorkEndTime(Timestamp workEndTime) {
        this.workEndTime = workEndTime;
    }

    @Basic
    @Column(name = "work_execution_time")
    public String getWorkExecutionTime() {
        return workExecutionTime;
    }

    public void setWorkExecutionTime(String workExecutionTime) {
        this.workExecutionTime = workExecutionTime;
    }

    @Basic
    @Column(name = "personnel_id")
    public Long getPersonnelId() {
        return personnelId;
    }

    public void setPersonnelId(Long personnelId) {
        this.personnelId = personnelId;
    }

    @Override
    public boolean equals(Object o) {
        if (this == o) {
            return true;
        }
        if (o == null || getClass() != o.getClass()) {
            return false;
        }
        WorkEntity that = (WorkEntity) o;
        return Objects.equals(workId, that.workId) &&
                Objects.equals(projectId, that.projectId) &&
                Objects.equals(workName, that.workName) &&
                Objects.equals(workStartTime, that.workStartTime) &&
                Objects.equals(workEndTime, that.workEndTime) &&
                Objects.equals(workExecutionTime, that.workExecutionTime) &&
                Objects.equals(personnelId, that.personnelId);
    }

    @Override
    public int hashCode() {
        return Objects
                .hash(workId, projectId, workName, workStartTime, workEndTime, workExecutionTime,
                        personnelId);
    }

    @OneToMany(mappedBy = "tWorkByWorkId")
    @JsonIgnore
    public Collection<FieldLineEntity> gettFieldLinesByWorkId() {
        return tFieldLinesByWorkId;
    }

    public void settFieldLinesByWorkId(
            Collection<FieldLineEntity> tFieldLinesByWorkId) {
        this.tFieldLinesByWorkId = tFieldLinesByWorkId;
    }

    @OneToMany(mappedBy = "tWorkByWorkId")
    @JsonIgnore
    public Collection<FieldPointEntity> gettFieldPointsByWorkId() {
        return tFieldPointsByWorkId;
    }

    public void settFieldPointsByWorkId(
            Collection<FieldPointEntity> tFieldPointsByWorkId) {
        this.tFieldPointsByWorkId = tFieldPointsByWorkId;
    }

    @OneToMany(mappedBy = "tWorkByWorkId")
    @JsonIgnore
    public Collection<InteriorLineEntity> gettInteriorLinesByWorkId() {
        return tInteriorLinesByWorkId;
    }

    public void settInteriorLinesByWorkId(
            Collection<InteriorLineEntity> tInteriorLinesByWorkId) {
        this.tInteriorLinesByWorkId = tInteriorLinesByWorkId;
    }

    @OneToMany(mappedBy = "tWorkByWorkId")
    @JsonIgnore
    public Collection<InteriorPointEntity> gettInteriorPointsByWorkId() {
        return tInteriorPointsByWorkId;
    }

    public void settInteriorPointsByWorkId(
            Collection<InteriorPointEntity> tInteriorPointsByWorkId) {
        this.tInteriorPointsByWorkId = tInteriorPointsByWorkId;
    }

    @OneToMany(mappedBy = "tWorkByWorkId")
    @JsonIgnore
    public Collection<ResultLineEntity> gettResultLinesByWorkId() {
        return tResultLinesByWorkId;
    }

    public void settResultLinesByWorkId(
            Collection<ResultLineEntity> tResultLinesByWorkId) {
        this.tResultLinesByWorkId = tResultLinesByWorkId;
    }

    @OneToMany(mappedBy = "tWorkByWorkId")
    @JsonIgnore
    public Collection<ResultLineAttrEntity> gettResultLineAttrsByWorkId() {
        return tResultLineAttrsByWorkId;
    }

    public void settResultLineAttrsByWorkId(
            Collection<ResultLineAttrEntity> tResultLineAttrsByWorkId) {
        this.tResultLineAttrsByWorkId = tResultLineAttrsByWorkId;
    }

    @OneToMany(mappedBy = "tWorkByWorkId")
    @JsonIgnore
    public Collection<ResultPointEntity> gettResultPointsByWorkId() {
        return tResultPointsByWorkId;
    }

    public void settResultPointsByWorkId(
            Collection<ResultPointEntity> tResultPointsByWorkId) {
        this.tResultPointsByWorkId = tResultPointsByWorkId;
    }

    @OneToMany(mappedBy = "tWorkByWorkId")
    @JsonIgnore
    public Collection<ResultPointAttrEntity> gettResultPointAttrsByWorkId() {
        return tResultPointAttrsByWorkId;
    }

    public void settResultPointAttrsByWorkId(
            Collection<ResultPointAttrEntity> tResultPointAttrsByWorkId) {
        this.tResultPointAttrsByWorkId = tResultPointAttrsByWorkId;
    }

    @OneToMany(mappedBy = "tWorkByWorkId")
    @JsonIgnore
    public Collection<RtkPointEntity> gettRtkPointsByWorkId() {
        return tRtkPointsByWorkId;
    }

    public void settRtkPointsByWorkId(
            Collection<RtkPointEntity> tRtkPointsByWorkId) {
        this.tRtkPointsByWorkId = tRtkPointsByWorkId;
    }

    @ManyToOne
    @JoinColumn(name = "project_id", referencedColumnName = "project_id",insertable = false,updatable = false)
    public ProjectEntity gettProjectByProjectId() {
        return tProjectByProjectId;
    }

    public void settProjectByProjectId(ProjectEntity tProjectByProjectId) {
        this.tProjectByProjectId = tProjectByProjectId;
    }

    @ManyToOne
    @JoinColumn(name = "personnel_id", referencedColumnName = "personnel_id",insertable = false,updatable = false)
    public PersonnelEntity gettPersonnelByPersonnelId() {
        return tPersonnelByPersonnelId;
    }

    public void settPersonnelByPersonnelId(PersonnelEntity tPersonnelByPersonnelId) {
        this.tPersonnelByPersonnelId = tPersonnelByPersonnelId;
    }
    @OneToMany(mappedBy = "tWorkByWorkId")
    @JsonIgnore
    public Collection<FileEntity> gettFilesByWorkId() {
        return tFilesByWorkId;
    }

    public void settFilesByWorkId(Collection<FileEntity> tFilesByWorkId) {
        this.tFilesByWorkId = tFilesByWorkId;
    }
}
